function HCP_CDebug() {
	var container = null;
	var list = new Array();
	this.createOutput = function () {
		// has the debugger already been started
		if (container != null) {
			return;
		}
		container = document.createElement('div');
		container.setAttribute('id', 'hcp_debug_output');
		/* bind it to the given container or the body */
		document.body.appendChild(container);
		/* fix the style to display it correctly */
		container.style.position = "relative";
		container.style.display = 'block';
	};
	this.println = function (msg) {
		if (list.length > 5) {
			for(var i = 1; i < list.length; i++) {
				list[i-1] = list [i];
			}
			list[5] = msg;
		} else {
			list[list.length] = msg;
		}
		var str = "";
		for (var i = 0; i < list.length; i++) {
			str += list[i]+"<BR>";
		}
		if (container != null) {
			container.innerHTML = str;
		}
	};
}

var Debug = new HCP_CDebug();